Another important form-level validation option is to check the length of the input string. You need three new properties: CheckSize (Boolean), MinLength (integer), and MaxLength (integer). The code in Listing 5.30 shows the modifications to the general declaration section of the UserControl.
Listing 5.30. Modifying the declaration section of VText.
' ------------------------------------------------
' CheckSize values
'
' event list
Public Event CheckSizeError(vValue)
' Properties
Dim m_CheckSize As Boolean
Dim m_MinLength As Integer
Dim m_MaxLength As Integer
' Default values
Const m_def_CheckSize = 0
Const m_def_MinLength = 0
Const m_def_MaxLength = 0
Next, update the InitProperties event to set the default values for these new properties. See Listing 5.31 for code to add to the InitProperties event.
Now, you need to modify the ReadProperties and WriteProperties events for the VText control. Listing 5.32 shows you how to modify the ReadProperties event.
Listing 5.32. Modifying the ReadProperties event.
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
'
' read design-time property values
'